	<style type="text/css">
		.answer_panel{
			display:none;	
		}
		.btnanswer{
			cursor:pointer;
			color:#00CC33
		}
		.btnanswered{
			cursor:pointer;
			color:red;
		}
	</style>
    <h2>Comment</h2>
	<?
			if($_SERVER['HTTP_HOST'] == "localhost"){
				$host = 	$_SERVER['HTTP_HOST']."/subkamol";
			}else{
				$host = $_SERVER['HTTP_HOST'];
			}
			$cment  = Q2("select * from post_comment pc
			inner join product p on p.pd_id = pc.post_id
			left join images i on i.na_id = p.pd_id
			where pc.pauthor = 0
			order by pc.padminfeedback  ASC , pc.pcomment_update DESC ,  pc.ampm DESC");
			$i = 1;//print_r($cment);
			foreach($cment as $c){
		?>
				 <div>
                 		<img  src = "./images/cancel_f2-swap.png"  style="width:15px;height:15px;cursor:pointer;" onclick = "
                        if(confirm('Do you want to delete this comment ?')){
                        		delcment('<?=$c[pcomment_id]?>');
                                $(this).parent().hide();
                        }
                        " />
						<a  href = "http://<?=$host."/index.php?pd_id=".$c['pd_id']."&img_id=".$c['img_id']?>" target="_new"><?=$c["pcomment_update"]." : ".$c["pd_name"]." / ".$c["pd_name2"]?></a>
                        
                        <?
                        	if($c['padminfeedback'] == 0){
								echo "<span  class = 'btnanswer'>answer</span>";
							}else{
								echo "<span  class = 'btnanswered'>answered</span>";
							}
						?>
                        <div style="word-wrap:break-word" class = "answer_panel">
                        	<b><?=$c['writter_name']." says "?></b><span><?=$c['pcomment_des']?></span>
                            <div >
                            	<span>Answer </span><br/>
                                <textarea  style = "border:solid 1px #CCC; width:100%;height:100px;"></textarea>
                                <input type = "button"  value = "answer" onclick = "addcment('<?=$c[pd_id]?>' , '<?=$c[pcomment_id]?>');" / >
                            </div>
                        </div>
				 </div>
		 <?
				$i++;
			}
		 ?>
         
		 <script type="text/javascript">
		 	$(document).ready(function(e) {
				   $(".btnanswer , .btnanswered").click(function(e) {
					   		$('textarea').removeAttr('name');
							$('.answer_panel:visible').toggle('fast');
							
							$(this).parent().children('.answer_panel:hidden').toggle('fast');
							$(this).parent().find('textarea').attr({'name' : 'des'});
							
					 });
					 
            });
			function addcment(id,pcomment_id){
					var des = $('textarea[name=des]').val();//alert($('textarea[name=des]').val());
					showcment('','' , 'ajax_admin_cment.php?des='+des+'&id='+id+'&pcomment_id='+pcomment_id+'&act=add&tables=product&email=<?=$replyMail?>');	
					$('.answer_panel:visible').parent().children('.btnanswer').addClass('btnanswered');$('.answer_panel:visible').parent().children('.btnanswer').text('answered');
					$('.answer_panel:visible').parent().children('.btnanswer').removeClass('btnanswer');
			}
			function delcment(pcomment_id){
					deletecment('','' , 'ajax_admin_cment.php?pcomment_id='+pcomment_id+'&act=del&tables=product');
			}
		 </script>
          